import 'dart:convert';

import 'package:safetymonitor/app/data/common/choice_bean.dart';
import 'package:safetymonitor/generated/json/base/json_field.dart';
import 'package:safetymonitor/generated/json/knowledge_base_type_tree_entity.g.dart';

export 'package:safetymonitor/generated/json/knowledge_base_type_tree_entity.g.dart';

@JsonSerializable()
class KnowledgeBaseTypeTreeEntity implements TreeChoiceIface {
  KnowledgeBaseTypeTreeEntity();

  factory KnowledgeBaseTypeTreeEntity.fromJson(Map<String, dynamic> json) => $KnowledgeBaseTypeTreeEntityFromJson(json);

  late int id;
  late int createTime;
  String label = '';
  late int pid;
  List<KnowledgeBaseTypeTreeEntity>? children;

  Map<String, dynamic> toJson() => $KnowledgeBaseTypeTreeEntityToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }

  @override
  List<KnowledgeBaseTypeTreeEntity>? get treeChildren => children;

  @override
  String get treeId => id.toString();

  @override
  String get treeName => label;
}
